home *** CD-ROM | disk | FTP | other *** search
-
- myname db 50 dup(0)
- myserial db 100 dup(0)
-
-
- serialgencode: ; starts with length of name in eax
-
- pushad
- lea ebx,[eax] ; copy length into ebx
- lea edi, myserial ; where i'm going to put the ascii serial
- lea esi, myname ; the address of the name, NULL terminated
- @serialloop:
- xor eax,eax
- mov al, byte ptr [esi] ; movsb, hehe, get letter from name into EAX
- inc esi
- test al,al ; check for ASCiiZ (NULL)
- jz finishedcalc
-
- imul eax,11 ; value=letter*11
-
- cdq
- lea ecx,[ebx] ; copy length into ECX
- idiv ecx ; value=value / length
-
- ; eax= number for the serial, just need to convert to ascii hex
-
- rol ax,8 ; my dodgy HEX to ASCii converter
- and al,0fh
- test al,al
- je misshigh ; skip the high byte of ax, since its only a 1 byte value
- mov dl,al
- add dl,30h
- cmp dl, 39h
- jg @letter1
- done1:
- mov byte ptr [edi],dl
- inc edi
- misshigh:
- rol ax,4
-
- and al,0fh
- mov dl,al
- add dl,30h
- cmp dl, 39h
- jg @letter2
- done2:
- mov byte ptr [edi],dl
- inc edi
- rol ax,4
-
- and al,0fh
- mov dl,al
- add dl,30h
- cmp dl, 39h
- jg @letter3
- done3:
- mov byte ptr [edi],dl
- inc edi
- skip1:
- mov byte ptr [edi],0 ; NULL terminate Serial..
- jmp @serialloop
-
- @letter1: ; change dl to ascii letter 'A-F'
- add dl, 7
- jmp done1
- @letter2:
- add dl, 7
- jmp done2
- @letter3:
- add dl, 7
- jmp done3
- finishedcalc:
- popad
- ret